Skip to content

Conversation

@fqaiser94
Copy link
Contributor

What changes were proposed in this pull request?

Make WithFields Expression not foldable.

Why are the changes needed?

The following query currently fails on master brach:

sql("SELECT named_struct('a', 1, 'b', 2) a")
.select($"a".withField("c", lit(3)).as("a"))
.show(false)
// java.lang.UnsupportedOperationException: Cannot evaluate expression: with_fields(named_struct(a, 1, b, 2), c, 3)

This happens because the Catalyst optimizer sees that the WithFields Expression is foldable and tries to statically evaluate the WithFields Expression (via the ConstantFolding rule), however it cannot do so because WithFields Expression is Unevaluable.

Does this PR introduce any user-facing change?

Yes, queries like the one shared above will now succeed.
That said, this bug was introduced in Spark 3.1.0 which has yet to be released.

How was this patch tested?

A new unit test was added.

@SparkQA
Copy link

SparkQA commented Aug 3, 2020

Test build #126990 has finished for PR 29338 at commit 3b5af0e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Aug 3, 2020

Test build #126995 has finished for PR 29338 at commit 0adf620.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

the last commit just removes one test, we don't need to wait for jenkins.

Thanks, merging to master!

@cloud-fan cloud-fan closed this in 6d69068 Aug 4, 2020
@SparkQA
Copy link

SparkQA commented Aug 4, 2020

Test build #127051 has finished for PR 29338 at commit 0e1c028.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants